<template>
  <div class="test-progress-card">
    <div class="progress-header">
      <span class="progress-icon">🕒</span>
      <span class="progress-title">考试倒计时</span>
    </div>
    <div class="progress-timer">{{ formatTime(remainingTime) }}</div>
    <div class="progress-bar-wrap">
      <div class="progress-bar-bg">
        <div
          class="progress-bar-fg"
          :style="{ width: progressPercent + '%' }"
        ></div>
      </div>
      <div class="progress-bar-labels">
        <span class="progress-bar-left">已完成{{ answeredCount }}题</span>
        <span class="progress-bar-right">共{{ totalQuestions }}题</span>
      </div>
    </div>
  </div>
</template>
<script setup>
const props = defineProps({
  remainingTime: Number,
  progressPercent: Number,
  answeredCount: Number,
  totalQuestions: Number,
});
function formatTime(sec) {
  const h = String(Math.floor(sec / 3600)).padStart(2, "0");
  const m = String(Math.floor((sec % 3600) / 60)).padStart(2, "0");
  const s = String(sec % 60).padStart(2, "0");
  return `${h}:${m}:${s}`;
}
</script>
<style scoped>
.test-progress-card {
  width: 100%;
  background: #fff;
  border-radius: 10px;
  border: none;
  /* box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.04); */
  margin-bottom: 18px;
  padding: 32px 32px 28px 32px;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.progress-header {
  display: flex;
  align-items: center;
  font-size: 20px;
  color: #222;
  margin-bottom: 12px;
  font-weight: bold;
}
.progress-icon {
  font-size: 22px;
  margin-right: 8px;
  color: #bbb;
  font-weight: normal;
}
.progress-title {
  font-size: 20px;
  color: #222;
  font-weight: bold;
}
.progress-timer {
  font-size: 38px;
  color: #ff6700;
  font-weight: bold;
  margin-bottom: 22px;
  margin-top: 2px;
  letter-spacing: 2px;
  text-align: center;
}
.progress-bar-wrap {
  width: 100%;
  margin-top: 8px;
}
.progress-bar-bg {
  width: 100%;
  height: 18px;
  background: #ededed;
  border-radius: 12px;
  position: relative;
  overflow: hidden;
}
.progress-bar-fg {
  height: 100%;
  background: #2196f3;
  border-radius: 12px 0 0 12px;
  transition: width 0.3s;
}
.progress-bar-labels {
  display: flex;
  justify-content: space-between;
  margin-top: 6px;
  font-size: 15px;
  align-items: flex-end;
}
.progress-bar-left {
  color: #2196f3;
  font-weight: 500;
}
.progress-bar-right {
  color: #bbb;
  font-weight: 400;
}
</style>
